/*
 * 创建日期 2008-11-12
 *
 * 成都天和软件公司
 * 电话：028-85425861
 * 传真：028-85425861-8008
 * 邮编：610041 
 * 版权所有
 */
package  org.fantasy.common.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import  org.fantasy.common.util.ThreadMap;
import  org.fantasy.common.util.WebContext;

/**
 * 线程上下文监听
 * 
 * @author 王文成
 * @version 1.0
 * @since 2008-11-12
 */
public class WebContextFilter implements Filter {
	public static Log log = LogFactory.getLog(WebContextFilter.class);

	public void init(FilterConfig arg0) throws ServletException {

	}

	public void destroy() {
	}

	/**
	 * 过滤
	 * 
	 * @param request
	 * @param response
	 * @param filter
	 * @throws IOException
	 * @throws ServletException
	 */
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain filter) throws IOException,
			ServletException {
		ThreadMap.put(WebContext.HTTP_REQUEST, request);
		ThreadMap.put(WebContext.HTTP_RESPONSE, response);
		log.info("****************** ThreadContextFilter doFilter Complete! ******************");
		filter.doFilter(request, response);
	}

}
